package com.itheima.fastjson.controller;

import com.itheima.fastjson.pojo.IdCard;
import com.itheima.fastjson.pojo.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 *
 */
@RestController
public class DemoController {
    @RequestMapping("/user/{id}")
    public User findUserById(@PathVariable Integer id){

        List<IdCard> idCardList = new ArrayList<>();
        Calendar instance = Calendar.getInstance();
        instance.set(1990,10,10,10,10,10);
        IdCard card1 = new IdCard("1001",instance.getTime(),new BigDecimal("100.015"));
        idCardList.add(card1);
        instance.set(2000,9,9,9,9,9);
        IdCard card2 = new IdCard("1002",instance.getTime(),new BigDecimal("300.0123"));
        idCardList.add(card2);

        return new User(1,null,idCardList);
    }
}
